#ifndef __UNIT_H__
#define __UNIT_H__
#include "cocos2d.h"
#include "gofgame/dungeonkeeper/game/UnitType.h"
#include "gofgame/dungeonkeeper/game/skill/Buffer.h"
#include "gofgame/dungeonkeeper/game/plate.h"
#include "gofgame/dungeonkeeper/game/Target.h"
#include "SimpleAudioEngine.h"
#include "string.h"
USING_NS_CC;
using namespace CocosDenshion;
using namespace gofgame::dungeonkeeper::game::skill;

namespace gofgame {
	namespace dungeonkeeper {
		namespace game {
			class Hero;

			namespace unit{


				class Unit :public Target{
				public:
					Unit();
					~Unit();

					UnitType unitType;
					CCSprite *texture;
					CCArray *buffers;
					Plate *hpPlate;
					void draw();
					bool init();
					bool isMyUnit();
					void goPosition();
					int maxY;
					int minY;
				public :
					virtual void initData();
					virtual void doAI();
		   		    virtual void hurted(int atk);
					/*virtual void heroHurt(Hero *hero);*/
					void die();
				/*	void hurtFinish();*/
					void AddBuffer(Buffer *bufer);
					void RemoveBuffer(Buffer *buffer);
					bool isAdded(Buffer *bufer);
					void updateState();
					bool isAIUnit();
					CCRect boundingBox();
					void dropItem(int id);
				public:
				//	void draw();
					void update(float dt);
					float dTime;
					float hitRevocerCoutTime;
					CCPoint targetPoint;
					virtual void attack(Target *target);
					void updateAttack(float dt);
					void updateAi(float dt);
					int getRandInt(int min,int max);
					virtual void updateTargetState(float dt);
					int getHp();
					CCPoint getNowPoint();
					CCRect getBox();
					void initDirection();
					void initTargetInfo();
					bool isDead();
					CCPoint lastPostion;
					int direction;

				public:
					CCAnimate *attackAnimate;
					CCAnimate *hurtAnimate;
					CCAnimate *dieAnimate;
					CCAnimate *walkAnimate;

					bool initAnimation();
					void playIdelAni();
					void playMoveAni();
					void playAttatckAni();
					void playCastAni();
					void playHurtAni();
					void playDieAni();
				};
			}
		}
	}
}

#endif //__UNIT_H__
